<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="root"></div>
<script src="../../javascript/react.development.js"></script>
<script src="../../javascript/react-dom.development.js"></script>
<script src="../../javascript/prop-types.js"></script>
<script src="../../javascript/babel.min.js"></script>
<script type="text/babel">
    class App extends React.Component {
        constructor(props, context) {
            super(props, context)
            this.state = {count: 1}
        }

        render() {
            return (
                <div className="app">
                    /*回调函数形式的ref在更新的过程中会被执行两次，第一次传入参数null，第二次传入的参数为DOM元素*/
                    <input type="text" placeholder="点击按钮提示数据" ref={currentNode => {
                        console.log("回调函数形式ref的回调执行了", currentNode)
                        this.input = currentNode
                    }}/>
                    <button onClick={this.btnClick}>点击</button>
                    <button onClick={this.addCount}>点击{this.state.count}</button>
                </div>
            );
        }

        btnClick = () => {
            console.log(this.input.value)
        }
        addCount = () => {
            this.setState((state) => {
                return {
                    count: state.count += 1
                }
            })
        }
    }

    ReactDOM.render(<App></App>, document.querySelector("#root"))
</script>
</body>
</html>